(function ($) {
  "use strict";

  /****************************
   * Sticky Menu
   *****************************/
  $(window).on("scroll", function () {
    var scroll = $(window).scrollTop();
    if (scroll < 100) {
      $(".sticky-header").removeClass("sticky");
    } else {
      $(".sticky-header").addClass("sticky");
    }
  });

  /*****************************
   * Off Canvas Function
   *****************************/

  /************************************************
   * Scroll Top
   ***********************************************/
  $("body").materialScrollTop();

  // Case carousel
  $(".owl-carousel-case").owlCarousel({
    loop: true,
    margin: 15,
    nav: true,
    autoplay: true,
    autoplayTimeout: 7500,
    autoplayHoverPause: true,
    responsive: {
      0: {
        items: 1,
      },
      600: {
        items: 2,
      },
      1000: {
        items: 3,
      },
    },
  });
  // Service carousel
  $(".owl-carousel-service").owlCarousel({
    loop: true,
    margin: 30,
    nav: false,
    autoplay: true,
    autoplayTimeout: 7500,
    autoplayHoverPause: false,
    responsive: {
      0: {
        items: 1,
      },
      600: {
        items: 2,
      },
      1000: {
        items: 4,
      },
    },
  });
  // Testimonial carousel
  $(".owl-carousel-testimonial").owlCarousel({
    loop: true,
    margin: 30,
    nav: false,
    autoplay: true,
    autoplayTimeout: 5000,
    autoplayHoverPause: true,
    responsive: {
      0: {
        items: 1,
      },
      600: {
        items: 1,
      },
      1000: {
        items: 1,
      },
    },
  });

  $(".navbar-toggler").on("click", function () {
    $("#offcanvasNavbar2").addClass("show");
  });
  $(".btn-close-dark").on("click", function () {
    $("#offcanvasNavbar2").removeClass("show");
  });
  // 获取所有指示器
  $(".carousel-indicators-to").on("click", function () {
    console.log(1233);
    // 获取当前指示器的数据属性值
    var index = $(this).attr("data-slide-to");
    console.log(index);
    // 使用轮播插件的 `to` 方法跳转到指定的幻灯片
    $("#jzp-carousel-1").carousel(index);
  });
})(jQuery);
